<template>
  <div class="dashboard-container">
    <!-- 左侧导航栏 -->
    <div class="sidebar">
      <div class="nav-item" v-for="(item, index) in routeList" :key="index">
        <router-link
          :to="item.route"
          class="nav-link"
          :class="{ active: $route.path === item.route }"
        >
          {{ item.name }}
        </router-link>
      </div>
    </div>

    <!-- 右侧内容区域 -->
    <div class="content">
      <router-view v-slot="{ Component, route }">
        <component :is="Component" :key="route" />
      </router-view>
    </div>
  </div>
</template>

<script>
export default {
  name: 'Dashboard',
  data() {
    return {
      routeList: [
        { name: '客户管理', route: '/crm' },
        { name: '会员中心', route: '/vip' }
      ]
    }
  }
}
</script>

<style scoped>
.dashboard-container {
  display: flex;
  min-height: 100vh; /* 撑满视口高度 */
}

.sidebar {
  width: 200px;
  background-color: #f8f9fa;
  padding: 20px;
  /* 常驻定位（滚动时保持顶部固定） */
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto; /* 内容过多时显示滚动条 */
  border-right: 1px solid #e9ecef;
}

.nav-link {
  display: block;
  padding: 12px 16px;
  text-decoration: none;
  color: #333;
  border-radius: 4px;
  transition: all 0.3s ease;
}

.nav-link:hover,
.nav-link.active {
  background-color: #e9f5ff;
  color: #007bff;
  padding-left: 20px; /* 激活时增加内边距视觉效果 */
}

.content {
  flex-grow: 1;
  padding: 30px;
  background-color: #fefefe;
}
</style>
